function topto(number) {
    window.scrollTo({
        top: number * window.innerHeight + 1,
        behavior: "smooth"
    });
}
var sctop = function (num) {   //页面滚动
    let x = 0;
    const speed = 125;  //动画速度
    let position=num*(window.innerHeight);  //目标距离
    function step() {
        x++;
        if (x < speed) {
            if (x == speed - 1) {
                window.scrollTo(0, position);
            } else {
                window.scrollTo({
                    top: easeOutBounce(x / speed) * position
                })
                requestAnimationFrame(step);
            }
        }
    };
    step();
};
window.onload = function () {

}
const text = ["富强", "民主", "文明", "和谐", "自由", "平等", "公正", "法治", "爱国", "敬业", "诚信", "友善"];
    const color = ['#ff0000', '#eb4310', '#f6941d', '#fbb417', '#ffff00', '#cdd541', '#99cc33', '#3f9337', '#219167', '#239676', '#24998d', '#1f9baa', '#0080ff', '#3366cc', '#333399', '#003366', '#800080', '#a1488e', '#c71585', '#bd2158', '#eec142', '#FEEE6D'];
    window.onload= function(){
        document.querySelector("body").onclick= function(){
            let e = event || window.event;
            let textNum = Math.floor(Math.random()*text.length);
            let colorNUm = Math.floor(Math.random()*color.length);
            let x= e.pageX;
            let y= e.pageY;
            let flag = document.createElement("span");
            flag.append(""+text[textNum]+"");
            flag.style.zIndex=999999;
            flag.style.fontWeight="bold";
            flag.style.position="absolute";
            flag.style.top=y-20+"px";
            flag.style.left=x -15 + "px";
            flag.style.color=color[colorNUm];
            document.querySelector("body").append(flag);
            let timer;
            let i=180,m=[10,9,8,7,6,5,4,3,2,1,0,-1,-2,-3,-4,-5,-6,-7,-8,-9,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9],n=0;
            cancelAnimationFrame(timer);
            timer =requestAnimationFrame(function fn(){
                if(i>0)
                {
                    i--;
                    flag.style.opacity=i/180;
                    flag.style.top=y-15-(180-i)+'px';
                    flag.style.left=x -15 +m[n]+ "px";
                    if(i%2==0)
                    n++;
                    timer=requestAnimationFrame(fn);
                    if(n>m.length)
                    {
                        n=0
                    }
                }
                else{
                    cancelAnimationFrame(timer);
                    flag.remove();
                }
            });
            

        }
        var tr = document.querySelector(".t");
        tr.onclick = function () {
            sctop(1);
        }
    }

